package mymvc.ui
{
	import flash.display.DisplayObject;
	import flash.display.MovieClip;
	import flash.display.Sprite;
	import flash.events.Event;
	
	import mx.core.UIComponentDescriptor;
	import mx.events.MoveEvent;
	
	import mymvc.observer.ObserverData;
	import mymvc.observer.ObserverManager;
	import mymvc.event.ClassLoadCompleteEvent;
	import mymvc.util.ClassLoader;
	import mymvc.util.SWFLoader;


	public class UIManager
	{
		private static var uiManger:UIManager = null;
		private var parent:Sprite = null;
		/*
		 *  存储当前受管理的组件类,类型规定为“LoadUIInfo”
		 */
		private var uiArray:Array = null;
		
		private var currentManagerUI:String = null;
		private var currentUIIndex:int = -1;
		
		public function UIManager(parent:Sprite)
		{
			this.parent = parent;
			
		}
		
		public static function getInstance(parent:Sprite):UIManager{
			if(uiManger == null){
				uiManger = new UIManager(parent);
			}
			return uiManger;
		}		

		public function load(sourcePath:String,className:String):void{
			var loader:ClassLoader = null;
			loader = new ClassLoader();
			
			function onComplete(event:ClassLoadCompleteEvent):void{
				var clazz:Class = event.clazz;
				var data:ObserverData = new ObserverData();
				
				data.setData(event.className,clazz);
				
				ObserverManager.getInstance().execute(event.className,data);
			}
			
			loader.addEventListener(ClassLoadCompleteEvent.CLASS_LOAD_COMPLETE,onComplete);
			loader.loadClass(sourcePath,className);

		}
	
	}
}